import re
import json
import requests
from film_core import FilmSearch

def get_info(url = 'http://123ku.com/?m=vod-type-id-5.html'):

    regex = '<a href="/\?m=vod-detail-id-(\d+?).html"'

    r = requests.get(url)

    r.encoding = 'utf-8'

    html = r.text

    info = re.findall(regex, html)

    joint = 'http://123ku.com/?m=vod-detail-id-{}.html"'

    print(info)

    return [joint.format(i) for i in info]


def save_to_json():

    info = []

    for url in get_info():


        info_dict = FilmSearch().get_film_info_brach(url)

        info.append(info_dict)

        print(url)

    json_info = json.dumps(info)

    with open('50_film_info.json', 'w') as f:

        f.write(json_info)


save_to_json()

        

    

        

        

    

    
    
    
